package org.dey.controller;

import org.dey.pojo.Exercise;
import org.dey.pojo.Library;
import org.dey.pojo.PageVo;
import org.dey.service.LibraryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class LibraryConntroller {
    @Autowired
    LibraryService libraryService;

    @PostMapping("Library.action/{pageNum}/{pageSize}")
    public PageVo<Library> queryExercise(@RequestBody Library library,
                                         @PathVariable int pageNum,
                                         @PathVariable int pageSize) {

        PageVo<Library> queryuser = libraryService.queryLibrary(library, pageNum, pageSize);
        return queryuser;
    }

    //添加
    @PostMapping("addLibrary.action")
    public int insertExercise(@RequestBody Library library) {

        int insertuser = libraryService.insertLibrary(library);

        return insertuser;
    }

    @DeleteMapping("delLibrary.action/{id}")
    public int deleteExercise(@PathVariable int id) {
        return libraryService.deleteLibrary(id);
    }

    @GetMapping("qureyLibraryById.action/{id}")
    public Library queryLibraryByid(@PathVariable int id) {
        return libraryService.queryLibraryByid(id);
    }

    @PutMapping("updateLibrary.action")
    public int updateExercise(@RequestBody Library library) {
        return libraryService.updateLibrary(library);
    }
}
